package com.zyj.myapplication.Model;

import com.zyj.myapplication.Javabean.OrderInfo;
import com.zyj.myapplication.Javabean.User;
import com.zyj.myapplication.Javabean.UserCollect;
import com.zyj.myapplication.Javabean.UserInfo;
import com.zyj.myapplication.Javabean.UserOrder;
import com.zyj.myapplication.Javabean.UserShaitu;
import com.zyj.myapplication.Javabean.YueJian;
import com.zyj.myapplication.Service.UserService;

import java.util.List;

import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2017/9/28.
 */

public class UserModel {
    private Retrofit retrofit;

    public UserModel() {
        retrofit = new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl("http://172.24.10.175/workout/api.php/")
                .build();

    }

    public retrofit2.Call<User> login(String tel, String pwd) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getLogin(tel, pwd);
    }

    public retrofit2.Call<User> register(String tel, String pwd) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getRegister(tel, pwd);
    }

    public retrofit2.Call<YueJian> getYueJian() {
        UserService userService = retrofit.create(UserService.class);
        return userService.getYueJian();
    }

    public retrofit2.Call<User> getUserinfo(int userid) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getuserinfo("lgj98rfkiqvenhrk2o7oe2po81", userid);
    }

    public retrofit2.Call<UserInfo> updateName(int userid, String username) {
        UserService userService = retrofit.create(UserService.class);
        return userService.updatename("lgj98rfkiqvenhrk2o7oe2po81", userid, username);
    }

    public retrofit2.Call<Integer> updatePwd(int userid, String password) {
        UserService userService = retrofit.create(UserService.class);
        return userService.updatepwd("lgj98rfkiqvenhrk2o7oe2po81", userid, password);
    }

    public retrofit2.Call<List<UserShaitu>> getusershaitu(int userid) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getusershaitu("shaitu", "lgj98rfkiqvenhrk2o7oe2po81", userid);
    }

    public retrofit2.Call<List<UserCollect>> getcollect(int userid) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getcollect("fans", "lgj98rfkiqvenhrk2o7oe2po81", userid);
    }

    public retrofit2.Call<List<UserOrder>> getallorder(int userid) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getallorder("sign", userid, "pf2cmg5jk9p24f2mv1kjf55bo3");
    }

    public retrofit2.Call<List<UserOrder>> getfinorder(int vstate, int userid) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getordertype("sign", userid, vstate, "pf2cmg5jk9p24f2mv1kjf55bo3");
    }

    public retrofit2.Call<OrderInfo> getOrderInfo(String id, String type) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getOrder(id, type, "lgj98rfkiqvenhrk2o7oe2po81");
    }

    public retrofit2.Call<Integer> getTeaState(String fan_id, int userid) {
        UserService userService = retrofit.create(UserService.class);
        return userService.getTeaState(fan_id, userid, "1", "lgj98rfkiqvenhrk2o7oe2po81");
    }

    public retrofit2.Call<Integer> changeTeaState(int userid, String fan_id) {
        UserService userService = retrofit.create(UserService.class);
        return userService.changeTeaState("lgj98rfkiqvenhrk2o7oe2po81", userid, fan_id, "2");
    }
}
